home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994…tember: Reference Library / Dev.CD Sep 94.toast / Periodicals / develop / develop Issue 9 / develop 9 code / Tracks / DriverGlue.a < prev    next >
Encoding:
Text File  |  1992-11-16  |  14.7 KB  |  305 lines  |  [TEXT/MPS ]

  1.                 IMPORT         TPrime            
  2.                 IMPORT         TOpen
  3.                 IMPORT         TControl            
  4.                 IMPORT         TStatus            
  5.                 IMPORT         TClose    
  6.  
  7. * From SysEqu.a we get jIODone defined.
  8. * From Traps.a we get _Debugger defined.
  9. * From DriverGlue.incl.a we get the DbgInfo macro defined.  It was just taken from
  10. * Sample.a and all the other macros were deleted.
  11.                 PRINT    PUSH,OFF                                    ; don't print any of this stuff        
  12.                 INCLUDE    'SysEqu.a'
  13.                 INCLUDE    'Traps.a'    
  14.                 INCLUDE    'DriverGlue.incl.a'                ; all our macros and data templates
  15.                 PRINT    POP                                        ; restore the PRINT options
  16.  
  17. *********************************** Main ********************************************
  18. * We have to make this the first entry point in our application because the DRVR       *
  19. * header information must come first.  So, we just put our data defines inside the     *
  20. * "MAIN" procedure and then declare that as our entry point for Mr. Linker.            *
  21. * The bits in the HIGH byte (beware of this -- it bit me the first go-around because*
  22. * I forgot to put them in the HIGH byte), are defined for this DRVR as follows:     *
  23. * Bit 7 (most significant bit)        Undefined        False (0)                                *
  24. * Bit 6                                         dNeedLock        True (1)                                    *
  25. * Bit 5                                         dNeedTime        False (1)                                *
  26. * Bit 4                                         dNeedGoodBye    True (1)                                    *
  27. * Bit 3                                         dStatEnable        True (1)                                    *
  28. * Bit 2                                         dCtlEnable        True (1)                                    *
  29. * Bit 1                                         dWritEnable        True (0)                                    *
  30. * Bit 0 (least significant bit)         dReadEnable        True (0)                                    *
  31. * Which all adds up to: $7C.                                                                            *
  32. *************************************************************************************
  33.  
  34. HEADERDEF    PROC            EXPORT                                                
  35.                 IMPORT         TSEPrime            
  36.                 IMPORT         TSEOpen
  37.                 IMPORT         TSEControl            
  38.                 IMPORT         TSEStatus            
  39.                 IMPORT         TSEClose    
  40. TSEStartHdr    DC.W            $7C00                                ; Turn the proper bits on
  41.                                                                     ; dNeedLock<6>, dNeedGoodbye<4)
  42.                                                                     ; dReadEnable<3>, dWritEnable<2>
  43.                                                                     ; dCtlEnable<1>, dStatEnable<0>
  44.                 DC.W            $3C                                ; 60 ticks delay (if dNeedTime = True)
  45.                 DC.W            0                                    ; DRVREMask (for DAs only)
  46.                 DC.W            0                                    ; DRVRMenu (for DAs only)
  47.                 DC.W            TSEOpen-TSEStartHdr            ; Offset to open routine
  48.                 DC.W            TSEPrime-TSEStartHdr            ; Offset to prime routine
  49.                 DC.W            TSEControl-TSEStartHdr        ; Offset to control routine
  50.                 DC.W            TSEStatus-TSEStartHdr        ; Offset to Status routine.
  51.                 DC.W            TSEClose-TSEStartHdr            ; Offset to Close routine.
  52.                 DC.B            '.TRACE'                            ; Driver name.
  53.                 ALIGN            4                                    ; Align to next long word.
  54.                 ENDP
  55.  
  56. *********************************** TSEOpen ******************************************
  57. * This routine (and all like it below) performs three basic functions:                     *
  58. * 1) pushing the parameter block (A0), and the pointer to the DCE (A1) on the stack.*
  59. * 2) Testing to see whether the immediate bit was set in the trap word and RTSing    *
  60. * 3) Testing the result in D0.  If it's 1 the operation hasn't completed yet, so we    *
  61. *    just want to RTS.  If it's NOT 1, then we'll jump through jIODone.                    *
  62. * I put the standard procedure header in just so you'd see another example of it in    *
  63. * use.  I found Sample.a to be most helpful in much of what I did here.                    *
  64. *************************************************************************************
  65. TSEOpen        PROC            EXPORT                            ; any source file can use this routine
  66.  
  67. StackFrame    RECORD        {A6Link},DECR                    ; build a stack frame record
  68. Result1        DS.W            1                                    ; function's result returned to caller
  69. ParamBegin    EQU            *                                    ; start parameters after this point
  70. ParamSize    EQU            ParamBegin-*                    ; size of all the passed parameters
  71. RetAddr         DS.L            1                                    ; place holder for return address
  72. A6Link        DS.L            1                                    ; place holder for A6 link
  73. LocalSize    EQU             *                                    ; size of all the local variables
  74.                 ENDR
  75.  
  76.                 WITH            StackFrame                        ; cover our local stack frame
  77.                 LINK            A6,#LocalSize                    ; allocate our local stack frame
  78.                 
  79.                 
  80.                  MOVEM.L         D1-D3/A0-A4,-(A7)               ;Save registers (V1.1A)
  81.                 MOVE.L        A1,-(A7)                            ;Put address of DCE onto stack
  82.                 MOVE.L        A0,-(A7)                            ;Put address of ParamBlock onto stack
  83.                 JSR             TOpen                        ;Call our routine.
  84.                 ADDQ.W        #$8,A7                            ;Take off A0 and A1 we pushed.
  85.                 ADDA.L        #ParamSize,SP                    ;strip all of the caller's parameters
  86.                 MOVEM.L         (A7)+,D1-D3/A0-A4            ;Restore registers (V1.1A)
  87.                 SWAP            D0                                    ;Save result in MostSig Word
  88.                 MOVE.W        ioTrap(A0),D0                    ;move ioTrap into register so we can test
  89.                 SWAP            D0                                    ;Back again
  90.                 BTST            #(noQueueBit+16), D0            ;Test the bit.
  91.                 BNE.S            OpenRTS                            ;If Z = 0, then noQueueBit set -- branch
  92.  
  93.                 CMP.W            #$1,D0                            ;Compare result with 1
  94.                 BEQ.S            OpenRTS                            ;Not equal to zero so RTS.
  95.                 UNLK            A6                                    ;destroy the link
  96.                 MOVE.L        jIODone,-(A7)                    ;Put jIODone on the stack
  97.                 RTS                                                ;return to the caller
  98.                 
  99. OpenRTS        UNLK            A6                                    ;destroy the link
  100.                 RTS                                                ;return to the caller
  101.                 DbgInfo        TSEOpen                            ;this name will appear in the debugger
  102.                 ENDP
  103.  
  104.  
  105. *********************************** TSEPrime *****************************************
  106. * This routine (and all like it below) performs three basic functions:                     *
  107. * 1) pushing the parameter block (A0), and the pointer to the DCE (A1) on the stack.*
  108. * 2) Testing to see whether the immediate bit was set in the trap word and RTSing    *
  109. * 3) Testing the result in D0.  If it's 1 the operation hasn't completed yet, so we    *
  110. *    just want to RTS.  If it's NOT 1, then we'll jump through jIODone.                    *
  111. * I put the standard procedure header in just so you'd see another example of it in    *
  112. * use.  I found Sample.a to be most helpful in much of what I did here.                    *
  113. *************************************************************************************
  114. TSEPrime        PROC            EXPORT                            ; any source file can use this routine
  115.  
  116. StackFrame    RECORD        {A6Link},DECR                    ; build a stack frame record
  117. Result1        DS.W            1                                    ; function's result returned to caller
  118. ParamBegin    EQU            *                                    ; start parameters after this point
  119. ParamSize    EQU            ParamBegin-*                    ; size of all the passed parameters
  120. RetAddr         DS.L            1                                    ; place holder for return address
  121. A6Link        DS.L            1                                    ; place holder for A6 link
  122. LocalSize    EQU             *                                    ; size of all the local variables
  123.                 ENDR
  124.  
  125.                 WITH            StackFrame                        ; cover our local stack frame
  126.                 LINK            A6,#LocalSize                    ; allocate our local stack frame
  127.                 
  128.                 
  129.                  MOVEM.L         D1-D3/A0-A4,-(A7)               ;Save registers (V1.1A)
  130.                 MOVE.L        A1,-(A7)                            ;Put address of DCE onto stack
  131.                 MOVE.L        A0,-(A7)                            ;Put address of ParamBlock onto stack
  132.                 JSR             TPrime                        ;Call our routine.
  133.                 ADDQ.W        #$8,A7                            ;Take off A0 and A1 we pushed.
  134.                 ADDA.L        #ParamSize,SP                    ;strip all of the caller's parameters
  135.                 MOVEM.L         (A7)+,D1-D3/A0-A4            ;Restore registers (V1.1A)
  136.                 SWAP            D0                                    ;Save result in MostSig Word
  137.                 MOVE.W        ioTrap(A0),D0                    ;move ioTrap into register so we can test
  138.                 SWAP            D0                                    ;Back again
  139.                 BTST            #(noQueueBit+16), D0            ;Test the bit.
  140.                 BNE.S            PrimeRTS                            ;If Z = 0, then noQueueBit set -- branch
  141.  
  142.                 CMP.W            #$1,D0                            ;Compare result with 1
  143.                 BEQ.S            PrimeRTS                            ;Not equal to zero so RTS.
  144.                 UNLK            A6                                    ;destroy the link
  145.                 MOVE.L        jIODone,-(A7)                    ;Put jIODone on the stack
  146.                 RTS                                                ;return to the caller
  147.                 
  148. PrimeRTS        UNLK            A6                                    ;destroy the link
  149.                 RTS                                                ;return to the caller
  150.                 DbgInfo        TSEPrime                            ;this name will appear in the debugger
  151.                 ENDP
  152.  
  153.  
  154.  
  155.  
  156. *********************************** TSEControl ***************************************
  157. * This routine (and all like it below) performs three basic functions:                     *
  158. * 1) pushing the parameter block (A0), and the pointer to the DCE (A1) on the stack.*
  159. * 2) Testing to see whether the immediate bit was set in the trap word and RTSing    *
  160. * 3) Testing the result in D0.  If it's 1 the operation hasn't completed yet, so we    *
  161. *    just want to RTS.  If it's NOT 1, then we'll jump through jIODone.                    *
  162. * I put the standard procedure header in just so you'd see another example of it in    *
  163. * use.  I found Sample.a to be most helpful in much of what I did here.                    *
  164. *************************************************************************************
  165. TSEControl    PROC            EXPORT                            ; any source file can use this routine
  166.  
  167. StackFrame    RECORD        {A6Link},DECR                    ; build a stack frame record
  168. Result1        DS.W            1                                    ; function's result returned to caller
  169. ParamBegin    EQU            *                                    ; start parameters after this point
  170. ParamSize    EQU            ParamBegin-*                    ; size of all the passed parameters
  171. RetAddr         DS.L            1                                    ; place holder for return address
  172. A6Link        DS.L            1                                    ; place holder for A6 link
  173. LocalSize    EQU             *                                    ; size of all the local variables
  174.                 ENDR
  175.  
  176.                 WITH            StackFrame                        ; cover our local stack frame
  177.                 LINK            A6,#LocalSize                    ; allocate our local stack frame
  178.                 
  179.                  MOVEM.L         D1-D3/A0-A4,-(A7)               ;Save registers (V1.1A)
  180.                 MOVE.L        A1,-(A7)                            ;Put address of DCE onto stack
  181.                 MOVE.L        A0,-(A7)                            ;Put address of ParamBlock onto stack
  182.                 JSR             TControl                    ;Call our routine.
  183.                 ADDQ.W        #$8,A7                            ;Take off A0 and A1 we pushed.
  184.                 ADDA.L        #ParamSize,SP                    ;strip all of the caller's parameters
  185.                 MOVEM.L         (A7)+,D1-D3/A0-A4            ;Restore registers (V1.1A)
  186.                 SWAP            D0                                    ;Save result in MostSig Word
  187.                 MOVE.W        ioTrap(A0),D0                    ;move ioTrap into register so we can test
  188.                 SWAP            D0                                    ;Back again
  189.                 BTST            #(noQueueBit+16), D0            ;Test the bit.
  190.                 BNE.S            ControlRTS                        ;If Z = 0, then noQueueBit set -- branch
  191.  
  192.                 CMP.W            #$1,D0                            ;Compare result with 1
  193.                 BEQ.S            ControlRTS                        ;Not equal to zero so RTS.
  194.                 UNLK            A6                                    ;destroy the link
  195.                 MOVE.L        jIODone,-(A7)                    ;Put jIODone on the stack
  196.                 RTS                                                ;return to the caller
  197.                 
  198. ControlRTS    UNLK            A6                                    ;destroy the link
  199.                 RTS                                                ;return to the caller
  200.                 DbgInfo        TSEControl                        ;this name will appear in the debugger
  201.                 ENDP
  202.  
  203.  
  204.  
  205.  
  206. *********************************** TSEStatus ****************************************
  207. * This routine (and all like it below) performs three basic functions:                     *
  208. * 1) pushing the parameter block (A0), and the pointer to the DCE (A1) on the stack.*
  209. * 2) Testing to see whether the immediate bit was set in the trap word and RTSing    *
  210. * 3) Testing the result in D0.  If it's 1 the operation hasn't completed yet, so we    *
  211. *    just want to RTS.  If it's NOT 1, then we'll jump through jIODone.                    *
  212. * I put the standard procedure header in just so you'd see another example of it in    *
  213. * use.  I found Sample.a to be most helpful in much of what I did here.                    *
  214. *************************************************************************************
  215. TSEStatus        PROC            EXPORT                            ; any source file can use this routine
  216.  
  217. StackFrame    RECORD        {A6Link},DECR                    ; build a stack frame record
  218. Result1        DS.W            1                                    ; function's result returned to caller
  219. ParamBegin    EQU            *                                    ; start parameters after this point
  220. ParamSize    EQU            ParamBegin-*                    ; size of all the passed parameters
  221. RetAddr         DS.L            1                                    ; place holder for return address
  222. A6Link        DS.L            1                                    ; place holder for A6 link
  223. LocalSize    EQU             *                                    ; size of all the local variables
  224.                 ENDR
  225.  
  226.                 WITH            StackFrame                        ; cover our local stack frame
  227.                 LINK            A6,#LocalSize                    ; allocate our local stack frame
  228.                 
  229.                 
  230.                  MOVEM.L         D1-D3/A0-A4,-(A7)               ;Save registers (V1.1A)
  231.                 MOVE.L        A1,-(A7)                            ;Put address of DCE onto stack
  232.                 MOVE.L        A0,-(A7)                            ;Put address of ParamBlock onto stack
  233.                 JSR             TStatus                    ;Call our routine.
  234.                 ADDQ.W        #$8,A7                            ;Take off A0 and A1 we pushed.
  235.                 ADDA.L        #ParamSize,SP                    ;strip all of the caller's parameters
  236.                 MOVEM.L         (A7)+,D1-D3/A0-A4            ;Restore registers (V1.1A)
  237.                 SWAP            D0                                    ;Save result in MostSig Word
  238.                 MOVE.W        ioTrap(A0),D0                    ;move ioTrap into register so we can test
  239.                 SWAP            D0                                    ;Back again
  240.                 BTST            #(noQueueBit+16), D0            ;Test the bit.
  241.                 BNE.S            StatusRTS                        ;If Z = 0, then noQueueBit set -- branch
  242.  
  243.                 CMP.W            #$1,D0                            ;Compare result with 1
  244.                 BEQ.S            StatusRTS                        ;Not equal to zero so RTS.
  245.                 UNLK            A6                                    ;destroy the link
  246.                 MOVE.L        jIODone,-(A7)                    ;Put jIODone on the stack
  247.                 RTS                                                ;return to the caller
  248.                 
  249. StatusRTS    UNLK            A6                                    ;destroy the link
  250.                 RTS                                                ;return to the caller
  251.                 DbgInfo        TSEStatus                        ;this name will appear in the debugger
  252.                 ENDP
  253.                 
  254.  
  255.  
  256.  
  257. *********************************** TSEClose *****************************************
  258. * This routine (and all like it below) performs three basic functions:                     *
  259. * 1) pushing the parameter block (A0), and the pointer to the DCE (A1) on the stack.*
  260. * 2) Testing to see whether the immediate bit was set in the trap word and RTSing    *
  261. * 3) Testing the result in D0.  If it's 1 the operation hasn't completed yet, so we    *
  262. *    just want to RTS.  If it's NOT 1, then we'll jump through jIODone.                    *
  263. * I put the standard procedure header in just so you'd see another example of it in    *
  264. * use.  I found Sample.a to be most helpful in much of what I did here.                    *
  265. *************************************************************************************
  266. TSEClose        PROC            EXPORT                            ; any source file can use this routine
  267.  
  268. StackFrame    RECORD        {A6Link},DECR                    ; build a stack frame record
  269. Result1        DS.W            1                                    ; function's result returned to caller
  270. ParamBegin    EQU            *                                    ; start parameters after this point
  271. ParamSize    EQU            ParamBegin-*                    ; size of all the passed parameters
  272. RetAddr         DS.L            1                                    ; place holder for return address
  273. A6Link        DS.L            1                                    ; place holder for A6 link
  274. LocalSize    EQU             *                                    ; size of all the local variables
  275.                 ENDR
  276.  
  277.                 WITH            StackFrame                        ; cover our local stack frame
  278.                 LINK            A6,#LocalSize                    ; allocate our local stack frame
  279.                 
  280.                 _Debugger                
  281.                  MOVEM.L         D1-D3/A0-A4,-(A7)               ;Save registers (V1.1A)
  282.                 MOVE.L        A1,-(A7)                            ;Put address of DCE onto stack
  283.                 MOVE.L        A0,-(A7)                            ;Put address of ParamBlock onto stack
  284.                 JSR             TClose                        ;Call our routine.
  285.                 ADDQ.W        #$8,A7                            ;Take off A0 and A1 we pushed.
  286.                 ADDA.L        #ParamSize,SP                    ;strip all of the caller's parameters
  287.                 MOVEM.L         (A7)+,D1-D3/A0-A4            ;Restore registers (V1.1A)
  288.                 SWAP            D0                                    ;Save result in MostSig Word
  289.                 MOVE.W        ioTrap(A0),D0                    ;move ioTrap into register so we can test
  290.                 SWAP            D0                                    ;Back again
  291.                 BTST            #(noQueueBit+16), D0            ;Test the bit.
  292.                 BNE.S            CloseRTS                            ;If Z = 0, then noQueueBit set -- branch
  293.  
  294.                 CMP.W            #$1,D0                            ;Compare result with 1
  295.                 BEQ.S            CloseRTS                            ;Not equal to zero so RTS.
  296.                 UNLK            A6                                    ;destroy the link
  297.                 MOVE.L        jIODone,-(A7)                    ;Put jIODone on the stack
  298.                 RTS                                                ;return to the caller
  299.                 
  300. CloseRTS        UNLK            A6                                    ;destroy the link
  301.                 RTS                                                ;return to the caller
  302.                 DbgInfo        TSEClose                            ;this name will appear in the debugger
  303.                 ENDP
  304.                 
  305.                 END